const { DataTypes } = require('sequelize');
// const sequelize = require('@/db/seq');
const sequelize = require("@/db/seq");

const LinkCategory = sequelize.define('link_category', {
  name: {
    type: DataTypes.STRING,
    allowNull: false,
    unique: true,
    comment: '分类名称'
  },
  description: {
    type: DataTypes.STRING,
    allowNull: true,
    comment: '分类描述'
  },
  order: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
    comment: '分类排序'
  }
}, {
  freezeTableName: true
});
// LinkCategory.sync({ alter: true });
LinkCategory.associate = (models) => {
  LinkCategory.hasMany(models.links, { foreignKey: 'category_id', as: 'links' });
};
module.exports = LinkCategory;